package com.hui.admin.controller;

import com.hui.admin.common.result.Result;
import com.hui.admin.common.result.Results;
import com.hui.admin.dto.request.LogPageRequestDTO;
import com.hui.admin.dto.response.LogPageResponseDTO;
import com.hui.admin.service.LogService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/api/log")
@RequiredArgsConstructor
public class LogController {

    private final LogService logService;

    /**
     * 获取日志数据
     */
    @GetMapping
    public Result<LogPageResponseDTO> getLogPageList(LogPageRequestDTO requestDTO) {
        return Results.success(logService.getLogPageList(requestDTO));
    }

    /**
     * 批量删除日志
     */
    @PostMapping("/batch")
    public Result<Void> deleteLogs(@RequestBody Map<String, Long[]> payload) {
        Long[] ids = payload.get("ids");
        logService.deleteLogs(ids);
        return Results.success();
    }
}
